﻿using System;
using System.Collections.Generic;
using System.Text;
using NDbUnit.Core;
using Spring.Data.Common;
using NDbUnit;
namespace CenterDateAchieve.Test.Init
{
    /// <summary>
    /// 数据库加载
    /// </summary>
    public class DbFixure
    {
        private NDbUnit.Core.INDbUnitTest mySqlDatabase;

        public DbFixure(ServerContextFixure serverContextFixure)
        {
            IDbProvider p = (IDbProvider) serverContextFixure.LoadObject(typeof (IDbProvider));
            
            
            mySqlDatabase = new NDbUnit.Core.SqlClient.SqlDbUnitTest(p.ConnectionString);
            

        }

        public INDbUnitTest DbUnit
        {
            get { return mySqlDatabase; }
        }

        /// <summary>
        /// 插入数据库
        /// </summary>
        public void Setup()
        {
            mySqlDatabase.PerformDbOperation(NDbUnit.Core.DbOperationFlag.CleanInsertIdentity);

        }
        public void Teardown()
        {
            mySqlDatabase.PerformDbOperation(NDbUnit.Core.DbOperationFlag.DeleteAll);

        }


    }
}
